﻿using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Gueei.Gallery.Web
{
	// Note: For instructions on enabling IIS6 or IIS7 classic mode, 
	// visit http://go.microsoft.com/?LinkId=9394801

	public class MvcApplication : HttpApplication
	{
		public static void RegisterGlobalFilters(GlobalFilterCollection filters)
		{
			filters.Add(new HandleErrorAttribute());
		}

		public static void RegisterRoutes(RouteCollection routes)
		{
			routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

			routes.MapRoute("GetImage", "image/get/{id}",
				new { controller = "Image", action = "Get" });

			routes.MapRoute("ViewImage", "image/view/{id}/{SetType}/{SetId}",
			                new{
			                		controller = "Image",
			                		action = "View",
			                		SetType = UrlParameter.Optional,
			                		SetId = UrlParameter.Optional
			                	});

			routes.MapRoute("Edit", "Edit/{id}/{action}",
				new {controller = "EditImage", action="index"});
			routes.MapRoute("Browse", "Browse/Tag/{name}", 
				new {controller = "Browse", action = "tag"});
			routes.MapRoute("Default", "{controller}/{action}/{id}", 
				new {controller = "Browse", action = "index", id = UrlParameter.Optional});

		}

		protected void Application_Start()
		{
			AppStart_NinjectMVC3.Start();

			AreaRegistration.RegisterAllAreas();
			RegisterGlobalFilters(GlobalFilters.Filters);
			RegisterRoutes(RouteTable.Routes);
		}

	}
}